<?php
class ProductUnitAction extends CommonAction {

	
	public $table = "product_unit" ;
	
	public function edit(){		
		$condition['id'] = $_REQUEST['id'];
		//dump($this->CommonSimplequery($condition, $this->table,1));
		$this->assign( "productUnitVo" , $this->CommonSimplequery($condition, $this->table,1));
		$this->display();
	}
	
	
	/**
	 * 修改状态 
	 * 
	 */
	public function statusHandle(){		
		$model = D( $this->table );		
		$id = $_REQUEST ['id'];		
		$condition['id'] = $id ;
		$vo = $this->CommonSimplequery($condition, $this->table,1);
		$data['status'];
		if($vo['status'] == 1){
			$data['status'] = 0  ;
		}else{
			$data['status'] = 1  ;
		}
   	    $this->resultHandle($model->where($condition)->save($data),"产品单位状态修改成功！","产品单位状态修改失败！") ;
	}
	
	/**
	 * 
	 * 新增产品类型
	 */
	public function addProductPayment(){
		$model = D( $this->table);	
		$data["name"] = $_REQUEST ['name'];		
		$data["summary"] = $_REQUEST ['summary'];		
		$data["createdate"] = date('Y-m-d H:i:s',time());
		$data["status"] = $_REQUEST ['status'];		
		
		$this->resultHandle($model->add($data),"新增产品单位成功！","新增产品单位失败！");
	}
	
	/**
	 * 
	 * 修改产品类型
	 */
	public function editProductType(){
		$model = D( $this->table );			
		$condition['id'] = $_REQUEST ['id'];		
		$vo = $this->CommonSimplequery($condition, $this->table,1);
		$data['status'];
		/*
		if($vo['status'] == 1){
			$data['status'] = 0  ;
		}else{
			$data['status'] = 1  ;
		}*/
		$data['status'] = $_REQUEST ['status'];	
		$data['name'] = $_REQUEST ['name'];
		$data['summary'] = $_REQUEST ['summary'];		
   	    $this->resultHandle($model->where($condition)->save($data),"修改产品单位成功！","修改产品单位失败！") ;
	}
	
	
	
}
?>